<?php
/**
* 发货人信息
*
* @author chenping<chenping@shopex.cn>
* @version $Id: b2cv1.php 2013-3-12 17:23Z
*/
class erpapi_shop_response_components_order_consigner extends erpapi_shop_response_components_order_abstract
{
    const _APP_NAME = 'ome';
    /**
     * 数据转换
     *
     * @return void
     * @author 
     **/
    public function convert()
    {   
        if ($this->_platform->_ordersdf['consigner']) {
            $this->_platform->_newOrder['consigner']['name']   = $this->_platform->_ordersdf['consigner']['name'];
            $this->_platform->_newOrder['consigner']['area']   = $this->_platform->_ordersdf['consigner']['area_state'] . '/' . $this->_platform->_ordersdf['consigner']['area_city'] . '/' . $this->_platform->_ordersdf['consigner']['area_district'];
            $this->_platform->_newOrder['consigner']['addr']   = $this->_platform->_ordersdf['consigner']['addr'];
            $this->_platform->_newOrder['consigner']['zip']    = $this->_platform->_ordersdf['consigner']['zip'];
            $this->_platform->_newOrder['consigner']['tel']    = $this->_platform->_ordersdf['consigner']['telephone'];
            $this->_platform->_newOrder['consigner']['email']  = $this->_platform->_ordersdf['consigner']['email'];
            $this->_platform->_newOrder['consigner']['mobile'] = $this->_platform->_ordersdf['consigner']['mobile'];
	    $this->_platform->_newOrder['consigner']['r_time'] = $this->_platform->_ordersdf['consigner']['r_time'];
        }
    }

    /**
     * 更新发货人
     *
     * @return void
     * @author 
     **/
    public function update()
    {
        if ($this->_platform->_ordersdf['consigner']) {
            $area = $this->_platform->_ordersdf['consigner']['area_state'] . '/' . $this->_platform->_ordersdf['consigner']['area_city'] . '/' . $this->_platform->_ordersdf['consigner']['area_district'];
            kernel::single('ome_func')->region_validate($area);

            $consigner['name']   = $this->_platform->_ordersdf['consigner']['name'];
            $consigner['area']   = $area;
            $consigner['addr']   = $this->_platform->_ordersdf['consigner']['addr'];
            $consigner['zip']    = $this->_platform->_ordersdf['consigner']['zip'];
            $consigner['tel']    = $this->_platform->_ordersdf['consigner']['telephone'];
            $consigner['email']  = $this->_platform->_ordersdf['consigner']['email'];
            $consigner['mobile'] = $this->_platform->_ordersdf['consigner']['mobile'];

            $diff_consigneer = array_udiff_assoc($consigner, $this->_platform->_tgOrder['consigner'],array($this,'comp_array_value'));
	    $consigner['r_time'] = $this->_platform->_ordersdf['consigner']['r_time'];
            if ($diff_consigneer) {
                $this->_platform->_newOrder['consigner'] = $diff_consigneer;
            }  
        }
    }
}
